package com.sgu6.sgu6_machine.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.RecyclerView;


import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.sgu6.redis.dto.ListGoodsSimpleDto;
import com.sgu6.sgu6_machine.ui.fragment.SelectF;

import java.util.HashMap;
import java.util.List;

public class PagerAdapter extends FragmentStateAdapter {

    private List<ListGoodsSimpleDto> listGoodsSimpleDtos;
    public HashMap<Integer, Fragment> mFragmentHashMap = new HashMap<>();

    public PagerAdapter(@NonNull FragmentActivity fragmentActivity,List<ListGoodsSimpleDto> listGoodsSimpleDtos) {
        super(fragmentActivity);
        this.listGoodsSimpleDtos = listGoodsSimpleDtos;
    }


    @NonNull
    @Override
    public Fragment createFragment(int pos) {
        SelectF fragment = (SelectF) mFragmentHashMap.get(pos);

//        if (fragment == null) {
//
//            fragment = SelectF.newInstance(listGoodsSimpleDtos.get(pos).goodsSortDtoList);
//            mFragmentHashMap.put(pos, fragment);
//        }
        return fragment;
    }


    @Override
    public int getItemCount() {
        return listGoodsSimpleDtos.size();
    }
}
